package com.ks.member.service.impl;

import com.ks.member.entity.Post;
import com.ks.member.entity.PostComment;
import com.ks.member.mapper.PostCommentMapper;
import com.ks.member.service.PostCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ks.member.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dCoder
 * @since 2022-04-17
 */
@Service
public class PostCommentServiceImpl extends ServiceImpl<PostCommentMapper, PostComment> implements PostCommentService {

    @Autowired
    PostService postService;

    @Override
    public void saveOne(String userId,String postid, String content) {
        PostComment postComment = new PostComment();
        Post post = postService.getById(postid);
        postComment.setPostId(postid);
        postComment.setCommentContent(content);
        postComment.setIsVisable(1);
        postComment.setReviewerId(userId);
        postComment.setUploaderId(post.getUploaderId());
        this.save(postComment);
    }
}
